<%@ include file="/jsp/controlHead.jsp"%>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<html>
<script type='text/javascript' src='<%=_base%>/dwr/interface/TeacherDWR.js'></script>
<script type="text/javascript">
function goSave(){
	teacherForm.submit();
}
 TrecNum=0;
 TmaxNum=0;
 var idToDel=-1;//选中tr时记录divId的id的值
 var selectNumber;
 var vals="";
 var used_amount;
 var info_val_type;
 function TaddRecN(tag_type,val,infovals,flag){
	  	var newTr = document.all.editTable.insertRow();
		newTr.onclick = Tclick_Handle;
		//document.all.editTable2.rows[TrecNum+1].bgColor = "#FFFFFF";
		var newTd0 = newTr.insertCell();		
		var newTd1 = newTr.insertCell();
		var newTd2 = newTr.insertCell();
		var newTd3 = newTr.insertCell();
		var newTd4 = newTr.insertCell();		
		var newTd5 = newTr.insertCell();
		newTd0.notnull = "true";
		newTd1.notnull = "true";
		newTd2.notnull = "true";
		newTd3.notnull = "true";		
	    newTd1.id="agentOtherInfo_val"+TrecNum;				
		newTd0.innerHTML = '<select id='+TrecNum+' name="tccs['+TrecNum+'].classid"  style="width:auto"/>';
		newTd1.innerHTML = '<select id='+TrecNum+100+' name="tccs['+TrecNum+'].courseid" style="width:auto"/>';
		newTd2.innerHTML ='<input type="text" size="12"  name="tccs['+TrecNum+'].riqi" /><img onclick="WdatePicker({el:\'tccs['+TrecNum+'].riqi\',dateFmt:\'yyyy-MM-dd\'})" src="<%=_base%>/images/icons/date.gif"  align="absmiddle">';
		newTd3.innerHTML ='<input type="text" name="tccs['+TrecNum+'].sal"/>';
		//newTd4.innerHTML='<input type="text" name="tccs['+TrecNum+'].note"/>';
		newTd4.innerHTML='<textarea  name="tccs['+TrecNum+'].note" rows="3" cols="30"  />';
		//浮动div
		var tipsDiv = '<div id="divId'+TrecNum+'" class="tipsClass'+TrecNum+'">我是浮动div'+TrecNum+'号</div>';
		$('body').append(tipsDiv);
		$('div.tipsClass'+TrecNum).css( {
			'top' : '0px',
			'left' : '0px',
			'position' : 'absolute',
			'padding' : '3px 5px',
			'background' : '#8FBC8F',
			'font-size' : 12 + 'px',
			'margin' : '0 auto',
			'text-align' : 'center',
			'width' : 'auto',
			'color' : '#fff',
			'opacity' : '0.0'
		});
		
		if(tag_type!=''){
			//编辑渠道操作
		newTd5.innerHTML='<input type="hidden" name="tccs['+TrecNum+'].used_amount"/>';	
		  var param_name=tag_type.split("~")[2];
		  if(flag=="1"){
		      initselect("AGENT_OTHER_INFO_TAG","tccs["+TrecNum+"].classid",'AREAID='+$d('area_id').value+'&PARAM_KIND=CHANNEL','0',tag_type);
		    }
		  else{
		      initselect("AGENT_OTHER_INFO_TAG","tccs["+TrecNum+"].courseid",'AREAID='+$d('area_id').value+'&PARAM_KIND=COMM','0',tag_type);
		  }				  	 		 		  		 
		  if(tag_type.split("~")[1]=="1"){		  		    	   
		    newTd1.innerHTML='<input type="text" id="tccs['+TrecNum+'].info_val" name="tccs['+TrecNum+'].info_val" onblur="checkVal(this,'+TrecNum+')" value="'+val+'"/>';		
		   }
		  else if(tag_type.split("~")[1]=="2"){		   		    
		    newTd1.innerHTML='<select name="tccs['+TrecNum+'].info_val"/>';		
		    changeselect("AGENT_CHANNEL_TAG_DETAIL","tccs["+TrecNum+"].info_val",'PARAM_NAME='+param_name, '0',val);		    		  		   		           
		  }
		  else{	
		   getNumber(TrecNum,infovals,param_name);  		   		  
		  }	
		}
		else{
	      	initselect("get_class","tccs["+TrecNum+"].classid",'', '0');
	      	initselect("get_course","tccs["+TrecNum+"].courseid",'', '0');
		   }								
		
		TrecNum += 1;
		TmaxNum += 1;			
	}
 
 function TrmRecN(flag){
	// alert(flag+"@@@"+TcurrRowIndex+"@@@"+TcurrRowIndex2);
    if(TcurrRowIndex==-1)
    {
       	alert("对不起，你首先必须选择要删除的行!");
		return;
	}
   	document.all.editTable.deleteRow(TcurrRowIndex);
	TcurrRowIndex=-1;
}
 function TSelectRow(objTR)
{
	var objTable =objTR.parentElement;
	for(var i=0;i<objTable.rows.length;i++)
	{
		objTable.rows[i].bgColor = "#FFFFFF";			
	}	
	objTR.bgColor="#FFFFAF";
	objTR.color="#000000";
	TcurrRowIndex = objTR.rowIndex;
}
//鼠标选择指定列
function Tclick_Handle()
{	
	TSelectRow(this);
}

$(document).ready(function(){
	loadData();
});

function loadData(){
	 TeacherDWR.getTeachers(function(dd){
		//alert(JSON.stringify(dd));
		$("#teacherId").searchSelect({"data":dd});
		});
 }
//getClasses
//getCourses
</script>
<body>
	<s:form theme="simple" method="post" action="teacher!save" name="teacherForm">
	<s:hidden name="teacher.teacherid"/>
	<input type="hidden" name="action_flag" value="99" />
	<div class="positionOn">
		您所在的位置：
		<a href="#">添加</a>
	</div>
	<div class="content">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td>教师名称： </td>
				<td>
					<input type="text" name="teacherIdName" id="teacherIdName">
					<input type="hidden" name="teacherId" id="teacherId">
				</td>
			</tr>
			 
			<tr>
				<td>
					&nbsp;
				</td>
				<td>
					&nbsp;
				</td>
				<td>
					&nbsp;
				</td>
				<td>
					<input name="Submit" type="button" class="Button" value="提交" onclick="goSave()" accesskey="S" title="快捷键ALT+S">
					<input name="Submit" type="button" class="Button" value="返回" onclick="window.close()" accesskey="B" title="快捷键ALT+B">
				</td>
			</tr>
		</table>
		
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
				<TR >
					<td   class="listTitle" >
						<a href='#' id='advance2'>▼<b>教师授课信息</b>
						</a>
					</td>
				</TR>
	   </table>
	   <div class="content" id='search2'>
		<table id="editTable" width="100%" border="0" cellpadding="0" cellspacing="0">		
		<tr>
		<td>
		班级<span class="required">*</span>		
		</td>
		<td>
		课程<span class="required">*</span>
		</td>
		<td>
		上课时间<span class="required">*</span>
		</td>
		<td>
		课酬<span class="required">*</span>
		</td>
		<td>
		备注
		</td>		
		</tr>
		</table>
		<table width="100%"><tr>
		<td>
					<input name="Submit" type="button" class="Button" value="添加"
								onclick="TaddRecN('','','','2')" accesskey="A" title="快捷键ALT+A">
					<input name="Submit" type="button" class="Button" value="删除"
								onclick="TrmRecN('2')" accesskey="D" title="快捷键ALT+D">
		</td>
		 <td width=60%>
		           &nbsp;
		        </td>
		</tr>
		</table>	
	</div>
	</s:form>
</body>
</html>
